var KEYCODE_ENTER = 13;
var KEYCODE_ESC = 27;
var KEYCODE_BCK = 8;
	$('[id^="boardItem"]').click(function(){
		bringNext();
	});


	function showUserCreator(){
		$('.textUser').each(function(){
			getUserInfo($(this).attr('id'));
	    });
	}
	
	function addAMessage(){		 
		var tempdata = {};
		tempdata['boardId'] = $("#jsSelectedBoardId").val();
		tempdata['date'] = returnToday();
		tempdata['discussion'] = $("#conversationText").val();
		tempdata['faceBookReference'] = '0';
		tempdata['userId'] =  $("#jsUserId").val();
		tempdata['status']='NEW';
		tempdata['parentDiscussionId'] = '5664313465372672';
		var objectHolder = document.getElementById('convlist');
		addBoardItemDiscussion(tempdata,objectHolder);
		
	}
	
	function replyToMessage(userId,facebookId){
		var tempdata = {};
		tempdata['boardId'] = $("#jsSelectedBoardId").val();
		tempdata['date'] = returnToday();
		tempdata['discussion'] = ""
		tempdata['faceBookReference'] = '0';
		tempdata['userId'] =  $("#jsUserId").val();
		tempdata['status']='APPROVED';
		tempdata['parentDiscussionId'] = userId;
		var objectHolder = document.getElementById('baordDiscussionList');
		addBoardItemDiscussion(tempdata,objectHolder,facebookId);
	}
	
	
	//REM:To clear admin panel controls after selecting other boards.
	function clearForm(){
		var object = document.getElementById("discussionText"); 
		$(object).val('');
		$("#baordDiscussionAdminPanel").slideUp();
	}
	
	//to show a textbox in same place of mesage
	function showEditMessagePanel(msg,discussionId,recfacebookId){
		var parent = document.getElementById('edit'+discussionId);
		var textbox =  document.createElement('textarea');
		textbox.id = 'textarea'+discussionId ;
		textbox.className = "input-text";
		textbox.style.width ="100%";
		textbox.innerHTML = msg;
		parent.innerHTML ='';
		parent.appendChild(textbox);
		textbox.onkeyup = function(e){
			  e = e || event;
			  
			  //console.log(String.fromCharCode(e.keyCode));
				  if (e.keyCode === KEYCODE_ENTER) {
					  var temp = document.getElementById('textarea'+discussionId);
					  parent.innerHTML = temp.innerHTML ;
					  if (recfacebookId!= undefined)
						  sendNotification(discussionId,recfacebookId);
					  updateDiscussion(discussionId,temp.innerHTML);
				  }
				  else if (e.keyCode === KEYCODE_ESC) {
					  parent.innerHTML = msg;
				  }
				  else if (e.keyCode === KEYCODE_BCK) {
					  textbox.innerHTML = textbox.innerHTML.substr(0,textbox.innerHTML.length-1);
					  console.log(textbox.innerHTML.substr(0,textbox.innerHTML.length-1));
				  }
				  else{
					  textbox.innerHTML+= String.fromCharCode(e.keyCode).toLowerCase();
				  }
			 }

		
	}
	
	//it s gonna to get depricated
	function showDiscussionPanel (msg,param,extraInfo){
		$("#addButton").hide();
		$("#saveButton").hide();
		$("#replyButton").hide();
		 
		$("#baordDiscussionAdminPanel").slideDown("slow");
		var object = document.getElementById("discussionText"); 
				 
		 
		 if(param == 'edit'){
			 $("#saveButton").show();
			 $(object).val(msg);
		 }
		 else if(param == 'reply'){
			 $("#replyButton").show();
			 $(object).val(msg + '@' + extraInfo + ': ' );
		 }
		 else{
			 $("#addButton").show();
		 }
			 
	}